﻿using DotNetExtensions.Core.Restful;
using Microsoft.AspNetCore.Mvc;
using Habi.Server.Services;
using Habi.Server.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Habi.Server.Controllers
{
    [Route("api/[controller]/[action]")]
    public class UserController : ControllerBase
    {
        private IUserService userService;
        public UserController(IUserService userService)
        {
            this.userService = userService;
        }

        [HttpPost]
        public ApiResult<LoginViewModel> Regist([FromBody] RegistUserModel regist)
        {
             var data = userService.Regist(regist);
            return ApiResult.OK(data);
        }

        [HttpPost]
        public ApiResult<LoginViewModel> Login([FromBody] LoginViewModel model)
        {
            var data = userService.Login(model);
            return ApiResult.OK(data);
        }
    }
}
